<template>
	<!-- 新契约工作列表模块-新单核保页面 -->
	<div class="fillcontain">
		<!-- 查询条件 -->
		<div class="fastQuery">
			<el-row>
				<el-col :span="2" class="fastQuery_title"><i class="el-icon-tickets"></i><span> 查询条件</span></el-col>
				<el-col :span="10">
					<el-badge :value="warnCount" class="item fastQuery_item">
						<el-button size="small" :class="{isActive:searchParams.queryType == 'WARN'}"
							@click="searchParams.queryType = 'WARN';getList(); ">预警
						</el-button>
					</el-badge>
					<el-badge :value="unprocessTotalCount" class="item fastQuery_item" type="warning">
						<el-button size="small" :class="{isActive:searchParams.queryType == 'TODO'}"
							@click="searchParams.queryType = 'TODO';getList();">全部
						</el-button>
					</el-badge>
				</el-col>
				<el-col :span="4" class="moreCondition">
					<span v-if="!isShow" @click="showorhide">更多条件 <i class="el-icon-d-arrow-right"></i></span>
					<span v-if="isShow" @click="showorhide">收起 <i class="el-icon-d-arrow-left"></i></span>
				</el-col>
				<el-col :span="8"></el-col>
			</el-row>
		</div>
		<!-- 查询表单 -->
		<el-form v-show="isShow" :model="searchParams" :rules="rules" ref="ruleForm" label-width="120px"
			class="search_container">
			<el-row>
				<el-col :span="6">
					<el-form-item label="保单号" prop="chdrnum">
						<el-input clearable v-model="searchParams.chdrnum" placeholder="保单号"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="受理号" prop="caseno">
						<el-input clearable v-model="searchParams.caseno" placeholder="受理号"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="电子投保标识" prop="appFrom">
						<el-select v-model="searchParams.appFrom" placeholder="电子投保标识">
							<el-option v-for="item in appFroms" :key="item.value" :label="item.label"
								:value="item.value"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="任务类型" prop="routeid">
						<el-select clearable v-model="searchParams.routeid" placeholder="任务类型">
							<el-option v-for="item in routeids" :key="item.value" :label="item.label"
								:value="item.value"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="6" class="common-box">
					<el-form-item label="保单类型" prop="risk">
						<el-select v-model="searchParams.risk" placeholder="保单类型" clearable>
							<el-option v-for="item in insmains" :key="item.value" :label="item.name"
								:value="item.value">
							</el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="6" class="common-box">
					<el-form-item label="机构" prop="risk">
						<el-select clearable v-model="searchParams.companyid" filterable placeholder="">
							<el-option v-for="item in ssyMap" :key="item.sbusiorgid" :label="item.sorgname"
								:value="item.sbusiorgid">
							</el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="6" class="common-box">
					<el-form-item label="渠道" prop="risk">
						<el-select v-model="searchParams.channel" placeholder="渠道" clearable>
							<el-option v-for="item in preChannelTypes" :key="item.value" :label="item.name"
								:value="item.value">
							</el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="投保人" prop="insuredname">
						<el-input clearable v-model="searchParams.policyholdername" placeholder="投保人"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="被保人" prop="policyholdername">
						<el-input clearable v-model="searchParams.insuredname" placeholder="被保人"></el-input>
					</el-form-item>
				</el-col>
        <!--  第二被保人需求  start      -->
        <el-col :span="6">
          <el-form-item label="第二被保人" prop="secondInsuredName">
            <el-input clearable v-model="searchParams.secondInsuredName" placeholder="第二被保人"></el-input>
          </el-form-item>
        </el-col>
        <!--  第二被保人需求  end      -->
				<el-col :span="6" class="text_center">
					<el-button type="primary" icon="el-icon-search" @click="subGetList"></el-button>
					<el-button type="primary" plain icon="el-icon-refresh" @click="resetSearch"></el-button>
				</el-col>
			</el-row>

		</el-form>

		<div class="contain">
			<!-- 操作按钮 -->
			<el-row>
				<el-col :span="24" class="pb15 pt5">
					<el-button type="danger" plain @click="hebao_select">核保处理</el-button>
					<el-dropdown class="ml10" @command="resetLvl" size="medium">
						<el-button type="danger">
							重置任务等级<i class="el-icon-arrow-down el-icon--right"></i>
						</el-button>
						<el-dropdown-menu slot="dropdown">
							<el-dropdown-item command="1">等级1</el-dropdown-item>
							<el-dropdown-item command="2">等级2</el-dropdown-item>
							<el-dropdown-item command="3">等级3</el-dropdown-item>
							<el-dropdown-item command="4">等级4</el-dropdown-item>
							<el-dropdown-item command="5">等级5</el-dropdown-item>
							<el-dropdown-item command="6">等级6</el-dropdown-item>
							<el-dropdown-item command="7">等级7</el-dropdown-item>
							<el-dropdown-item command="8">等级8</el-dropdown-item>
							<el-dropdown-item command="9">等级9</el-dropdown-item>
						</el-dropdown-menu>
					</el-dropdown>

					<div v-if="showNext" style="display: inline;">
						<el-button type="danger" style="margin-left: 10px;" plain v-for="(value,key) in nextNodeMap"
							:key="key" @click="exchangeNode(key)">{{nextNodeMap[key].destNodeName}}
						</el-button>
					</div>
					<el-button type="danger" plain @click="call_distr_task">请求派单</el-button>
				</el-col>
			</el-row>
			<!-- 查询结果列表 -->
			<div class="table_container">
				<el-table ref="multipleTable" v-loading="loading" :data="tableData" tooltip-effect="dark"
					highlight-current-row header-cell-class-name="table-header-class"
					@selection-change="handleSelectionChange" @row-dblclick="hebao_dubclick"
					@sort-change="changeTableSort" :row-style="rowStyle" empty-text="无符合查询条件任务">
					<el-table-column type="selection" :selectable="interceptVip"></el-table-column>
					<el-table-column property="risk" label="保单类型" align='center' show-overflow-tooltip min-width="80">
					</el-table-column>
					<el-table-column property="orgName" label="机构" align='center' show-overflow-tooltip min-width="120">
					</el-table-column>
					<el-table-column property="channel" label="渠道" align='center' show-overflow-tooltip min-width="50">
					</el-table-column>
					<el-table-column property="caseno" label="受理号" align='center' show-overflow-tooltip min-width="80">
					</el-table-column>
					<el-table-column property="chdrnum" label="保单号" align='center' show-overflow-tooltip
						min-width="100"></el-table-column>
					<el-table-column property="policyholdername" label="投保人" align='center' show-overflow-tooltip
						min-width="100"></el-table-column>
					<el-table-column property="insuredname" label="被保险人" align='center' show-overflow-tooltip
						min-width="100"></el-table-column>
					<el-table-column property="mainContractName" label="主合同名称" align='center' show-overflow-tooltip
						min-width="180"></el-table-column>
					<el-table-column property="taskLevel" label="任务级别" align='center' sortable show-overflow-tooltip
						min-width="100"></el-table-column>
					<el-table-column property="nodeName" label="任务类型" align='center' sortable show-overflow-tooltip
						min-width="100"></el-table-column>
					<el-table-column property="dealtime" label="最近处理时间" align='center' show-overflow-tooltip
						min-width="160"></el-table-column>
					<el-table-column property="remark" label="备注" align='center' show-overflow-tooltip min-width="120">
						<template slot-scope="scope">
							<el-link type="primary" @click="showRemark(scope.row.taskno)" :disabled="!interceptVip(scope.row, scope.index)">{{ scope.row.remark }}
							</el-link>
						</template>
					</el-table-column>
					<el-table-column property="taskChange" label="任务流转" align='center' show-overflow-tooltip
						min-width="100">
						<template slot-scope="scope">
							<el-link type="primary" @click="showChange(scope.row.taskno)" :disabled="!interceptVip(scope.row, scope.index)">任务流转</el-link>
						</template>
					</el-table-column>
					<el-table-column fixed="right" property="imageInfo" label="影像信息" align='center'
						show-overflow-tooltip min-width="80">
						<template slot-scope="scope">
							<span class="operationIcon" @click="showImageList(scope.row.caseno)" :style="{'pointer-events':!interceptVip(scope.row, scope.index) ? 'none': ''}">
								<i class="el-icon-camera"></i>
							</span>
						</template>
					</el-table-column>
					<el-table-column fixed="right" label="操作" align='center' show-overflow-tooltip min-width="50">
						<template slot-scope="scope">
							<!-- <el-button type="text" size="small"  @click="hebao(scope.row.policyholderno,scope.row.insuredno)">核保</el-button> -->
							<span class="operationIcon"
								@click="hebao(scope.row.policyholderno,scope.row.insuredno,scope.row.caseno,scope.row.organ)" :style="{'pointer-events':!interceptVip(scope.row, scope.index) ? 'none': ''}">
								<i class="el-icon-receiving"></i>
							</span>
						</template>
					</el-table-column>
				</el-table>
				<el-row>
					<el-col :span="24">
						<div class="pagination">
							<el-pagination background v-if='paginations.total > 0' :page-sizes="paginations.pageSizes"
								:page-size="paginations.pageSize" :layout="paginations.layout"
								:total="paginations.total" :current-page='paginations.pageIndex'
								@current-change='handleCurrentChange' @size-change='handleSizeChange'>
							</el-pagination>
						</div>
					</el-col>
				</el-row>
			</div>
		</div>

		<!-- 备注-->
		<remark-list :business="'NB'" :taskNo="remarkTaskNo" :drawer="showRemarkFlag" @close="hideRemark"></remark-list>
		<task-change-list :business="'NB'" :taskNo="changeTaskNo" :drawer="showChangeFlag" @close="hideChange">
		</task-change-list>
		<!--影像列表-->
		<cdfs-image-list :drawer="showImageFlag" :applnum="showImageApplnum" @close="hideImageList"></cdfs-image-list>
	</div>
</template>


<script>
	import {
		mapGetters
	} from 'vuex'
	import {
		nbTaskResetLvl,
		page,
		findNbHeBaoList
	} from "@/api/taskCenter/nbTask";
  import {
    exchangeNode,
    getNextNodes,
    getNodeMap,
    getSsyOrgMap,
    warnOrTimeOutCount,
    unprocessTotalCount,
    warnOutSty, interceptVip
  } from "@/api/taskCenter/taskCommon";
	import constant from '@/utils/constant';
	import taskConstants, {
		getSelectList
	} from '@/utils/taskConstants';
	import remarkList from "../remarkList";
	import TaskChangeList from "../taskChangeList";
	import CdfsImageList from "@/page/common/cdfsImageList";
	import TaskConst from "@/api/taskManager/common"
	import {
		getMysqlInfo,
		getBranchByUserId
	} from '@/api/setting'
	import TaskConstants, {
		call
	} from "@/api/taskManager/common";
  import {Message} from "element-ui";
	export default {
		components: {
			CdfsImageList,
			TaskChangeList,
			remarkList
		},
		data() {
			return {
				organ: '',
				mysqlUserInfo: {}, //中台数据
				insmains: TaskConst.insmain, //保单类型
				preChannelTypes: taskConstants.preChannelType, //渠道
				warnCount: 0, //预警个数
				unprocessTotalCount: 0, //未完成任务
				ssyMap: {}, //机构对象
				nodeMap: {}, //节点对象
				nextNodeMap: {},
				showNext: false,
				isShow: false,
				remarkTaskNo: "",
				showRemarkFlag: false,
				changeTaskNo: "",
				showChangeFlag: false,
				showImageFlag: false,
				showImageApplnum: '',
				// 查询条件
				rules: {
					caseno: [{
						pattern: /^[0-9]*$/, //正则
						message: '受理号只能输入数字'
					}],
					chdrnum: [{
						pattern: /^[0-9]*$/, //正则
						message: '保单号只能输入数字'
					}],
					channel: [],
					taskRank: [],
					markNo: [],
					institution: [],
					acceptdate: [],
					order: []
				},
				searchParams: {
					pool: taskConstants.nbPoolType.NEW, //新单pool
					caseno: "", //受理号
					chdrnum: "", //保单号
					channel: "", //渠道
					appFrom: "", //来源
					routeid: "", //节点
					risk: '', //类型
					policyholdername: "", //投保人姓名
					insuredname: "", //被保人姓名
					companyid: "", //分公司
					riskClass: "", //险种
					groupno: "", //组号
					checkoutusrid: "", //检出人
					queryType: 'TODO',
					taskLevelOrder: "", //受理号
					taskTypeOrder: "routeid asc", //受理号
					taskDealtimeOrder: "dealtime asc",
					pageSize: "",
					pageNumber: "",
          secondInsuredName: "",// 第二被保人姓名
				},
				orderList: constant.order,
				multipleTable: [],
				tableData: [],
				appFroms: [],
				routeids: [{
					value: taskConstants.RouteId.hebao,
					label: "核保"
				}, {
					value: taskConstants.RouteId.yhzhhf,
					label: "照会回复"
				}],
				loading: false,
				//需要给分页组件传的信息
				paginations: {
					total: 0, // 总数
					pageIndex: 1, // 当前位于哪页
					pageSize: 20, // 1页显示多少条
					pageSizes: [5, 10, 15, 20], //每页显示多少条
					layout: "total, sizes, prev, pager, next, jumper" // 翻页属性
				},
				pickerOptions1: {
					disabledDate(time) {
						return time.getTime() > Date.now();
					}
				},
				isFirstEnter: false
			}
		},
		created() {
			this.nextNodes();
			//获取核保员是否是总公司人员
			let userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
			//获取核保员是否是总公司人员
			getMysqlInfo(userInfo.account).then(data => {
				this.mysqlUserInfo = data;
			});
			getBranchByUserId(userInfo.account).then (data => this.organ = data);
		},
		activated() {
			this.$destroyCacheKey()
			this.getList();
			document.onkeydown = (event) => {
				var e = event || window.event || arguments.callee.caller.arguments[0];
				if (e && e.keyCode == 113) {
					this.getList();
				}
			};

		},
		mounted() {
			setTimeout(() => {
				this.isFirstEnter = true;
			}, 100)
			this.appFroms = getSelectList(taskConstants.appFrom);
			getSsyOrgMap().then(data => this.ssyMap = data);
			getNodeMap().then(data => this.nodeMap = data);
		},
		methods: {
			rowStyle({
				row,
				rowIndex
			}) {
				return warnOutSty(row, this.nodeMap);
			},
			getOrgName(value) {
				if (this.ssyMap && this.ssyMap[value] && this.ssyMap[value].sorgname)
					return this.ssyMap[value].sorgname;
				else
					return value;
			},
			getNodeName(value) {
				if (this.nodeMap && this.nodeMap["NB" + "_" + value] && this.nodeMap["NB" + "_" + value].content)
					return this.nodeMap["NB" + "_" + value].content;
				else
					return value;
			},
			showRemark(taskNo) {
				this.remarkTaskNo = taskNo;
				this.showRemarkFlag = true;
			},
			showChange(taskNo) {
				this.changeTaskNo = taskNo;
				this.showChangeFlag = true;
			},
			hideRemark() {
				this.remarkTaskNo = "";
				this.showRemarkFlag = false;
			},
			hideChange() {
				this.changeTaskNo = '';
				this.showChangeFlag = false;
			},
			showorhide() {
				this.isShow = !this.isShow;
			},
			showImageList(applnum) {
				this.showImageApplnum = applnum;
				this.showImageFlag = true;
			},
			hideImageList() {
				this.showImageApplnum = '';
				this.showImageFlag = false;
			},
			//重置任务等级
			resetLvl(lvl) {
				this.$store.dispatch('loading/CHANGE_LOADING', true);
				let arr = [];
				this.$refs.multipleTable.selection.forEach(item => {
					arr.push(item.taskno);
				});
				if (arr.length <= 0) {
					this.$message.error("请选择任务！");
					this.$store.dispatch('loading/CHANGE_LOADING', false);
					return;
				}
				nbTaskResetLvl(lvl, arr).then(res => {
					this.$store.dispatch('loading/CHANGE_LOADING', false)
					if (res.resultCode == constant.SUCCESS) {
						this.getList();
					} else {
						this.$alert(res.resultMsg, '错误信息', {
							confirmButtonText: '确定',
							callback: action => {
								this.$message({
									type: 'error',
									message: `action: ${action}`
								});
							}
						});
					}
				}).catch(err => {
					this.$store.dispatch('loading/CHANGE_LOADING', false);
				})
			},
			// 查询列表
			getList() {
				//获取预警任务个数
				this.queryWarnCount();
				this.paginations.total = 0;
				this.tableData = [];
				this.$store.dispatch('loading/CHANGE_LOADING', true)
				this.searchParams.pageNumber = this.paginations.pageIndex;
				this.searchParams.pageSize = this.paginations.pageSize;
				page(this.searchParams).then(res => {
					console.log('参数', this.searchParams);
					console.log('结果', res);
					this.$store.dispatch('loading/CHANGE_LOADING', false)
					if (res.resultCode == constant.SUCCESS && res.data && res.data.list.length) {
						this.paginations.total = res.data.total;
						this.tableData = res.data.list;
						this.tableData.forEach(item => {
							item["orgName"] = this.getOrgName(item.organ);
							item["nodeName"] = this.getNodeName(item.routeid);
						})
					}

				}).catch(err => {
					this.$store.dispatch('loading/CHANGE_LOADING', false);
				})
			},
			//查询预警个数
			queryWarnCount() {
				let routeids = taskConstants.RouteId.hebao + "," + taskConstants.RouteId.yhzhhf;
				this.warnCount = 0;
				warnOrTimeOutCount(taskConstants.taskBusitype.NB, routeids).then(res => {
					console.log('结果', res);
					// this.$store.dispatch('loading/CHANGE_LOADING',false)
					if (res.resultCode == constant.SUCCESS && res.data) {
						this.warnCount = res.data;
					}
				}).catch(err => {
					// this.$store.dispatch('loading/CHANGE_LOADING',false);
				});
				unprocessTotalCount(taskConstants.taskBusitype.NB, routeids).then(res => {
					console.log('结果', res);
					// this.$store.dispatch('loading/CHANGE_LOADING',false)
					if (res.resultCode == constant.SUCCESS && res.data) {
						this.unprocessTotalCount = res.data;
					}
				}).catch(err => {
					// this.$store.dispatch('loading/CHANGE_LOADING',false);
				})
			},
			//获取核保、照会回复的下一节点
			nextNodes() {
				getNextNodes(taskConstants.RouteId.hebao, taskConstants.taskBusitype.NB).then(res => {
					// this.$store.dispatch('loading/CHANGE_LOADING',false)
					if (res.resultCode == constant.SUCCESS) {
						res.data.forEach(item => {
							this.nextNodeMap[item.destNode] = item;
						});
						this.showNext = true;
					}
				}).catch(err => {
					// this.$store.dispatch('loading/CHANGE_LOADING',false);
				});
				getNextNodes(taskConstants.RouteId.yhzhhf, taskConstants.taskBusitype.NB).then(res => {
					// this.$store.dispatch('loading/CHANGE_LOADING',false)
					if (res.resultCode == constant.SUCCESS) {
						res.data.forEach(item => {
							this.nextNodeMap[item.destNode] = item;
						});
						this.showNext = true;
					}
				}).catch(err => {
					// this.$store.dispatch('loading/CHANGE_LOADING',false);
				});
			},
			//任务流转
			exchangeNode(routeid) {
				this.$store.dispatch('loading/CHANGE_LOADING', true);
				let arr = [];
				this.$refs.multipleTable.selection.forEach(item => {
					arr.push(item.taskno);
				});
				if (arr.length <= 0) {
					this.$message.error("请选择任务！");
					this.$store.dispatch('loading/CHANGE_LOADING', false);
					return;
				}
				exchangeNode(arr, routeid).then(res => {
					this.$store.dispatch('loading/CHANGE_LOADING', false)
					if (res.resultCode == constant.SUCCESS) {
						this.getList();
					} else {
						this.$alert(res.resultMsg, '错误信息', null);
						this.getList();
					}
				}).catch(err => {
					this.$store.dispatch('loading/CHANGE_LOADING', false);
				})
			},
			//核保
			hebao(policyholderno, insuredno, caseno, organ) {
				let userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
				// //核保员需求--非总公司的核保员，只能核保本公司机构的单
				// if (this.mysqlUserInfo.headStatus != "0") {
				// 	if (this.organ != organ) {
				// 		this.$message.error("本单不是您所属机构的保单，不允许查看！");
				// 		return false;
				// 	}
				// }
				var userId = userInfo.account;
				this.$store.dispatch('loading/CHANGE_LOADING', true);
				findNbHeBaoList(policyholderno, insuredno).then(res => {
					if (res.resultCode == constant.SUCCESS) {
						console.log(this.$route.path);
						let path = this.$route.path;
						let applNum = caseno;
						//本单
						let thisCase = res.data.filter(item => item.distributionUserId == userId && item.caseno ==
							caseno);
						//本人的排除本单
						let arr = res.data.filter(item => item.distributionUserId == userId && item.caseno !=
							caseno);
						if (thisCase[0].acntchn01 != 'Y') {
							applNum = "";
						}
						//在建档被修改了
						let isChange = false;
						if (applNum != "" && thisCase[0].isChangeByJD == 'Y') {
							isChange = true;
							applNum = "";
						}
						//非本人的单
						let others = res.data.filter(item => item.distributionUserId != userId);
						if (others != undefined && others != null && others.length > 0) {
							var message = "存在投被保人相同的单，分配给了其他核保人员。\n"
							others.forEach(item => {
								message += ("受理号：" + item.caseno + "分配给了用户：" + item.distributionUserId) +
									"\n";
							})
							this.$alert(message, '提示信息', {
								confirmButtonText: '确定',
							});
						}
						let reg = /[0-9]+/;
						if (arr != undefined && arr != null && arr.length != 0) {
							let msg = "受理号:";
							let msgChange = "受理号:";
							if (applNum == "" && !isChange) {
								msg += caseno + "\n";
							}
							if (isChange) {
								msgChange += caseno + "\n";
							}
							arr.forEach(taskmain => {
								if (taskmain.acntchn01 != 'Y') {
									msg += taskmain.caseno + "\n"
								}
								if (taskmain.isChangeByJD == 'Y') {
									msgChange += taskmain.caseno + "\n"
								}
							})
							msg += "处于解锁状态，必须回EUIS操作";
							msgChange += "该受理号已在建档页面修改数据并保存，必须从建档页面执行核保操作";
							if (reg.test(msg)) {
								this.$alert(msg, "提示信息", {
									confirmButtonText: '确定'
								});
							} else if (reg.test(msgChange)) {
								this.$alert(msgChange, "提示信息", {
									confirmButtonText: '确定'
								});
							}
							if (applNum == "" || isChange) {
								applNum = arr.filter(item => msg.indexOf(item.caseno) < 0 || msgChange.indexOf(item
									.caseno) < 0).map(item => item.caseno).join("_");
							} else {
								applNum += "_" + arr.filter(item => msg.indexOf(item.caseno) < 0 || msgChange
									.indexOf(item.caseno) < 0).map(item => item.caseno).join("_");
							}
						} else {
							if (applNum == "") {
								this.$alert("受理号:" + caseno + "处于解锁状态，必须回EUIS操作", "提示信息", {
									confirmButtonText: '确定'
								});
							}
							if (isChange) {
								this.$alert("受理号:" + caseno + "已在建档页面修改数据并保存，必须从建档页面执行核保操作", "提示信息", {
									confirmButtonText: '确定'
								});
							}
						}
						if (reg.test(applNum)) {
							if (path == "/home/taskCenter/newCovenantWordlist/newUnderwritList") {
								this.$router.push({
									path: "/underwrite/info/" + applNum + "/" + "hebao"
								});
							} else {
								this.$router.push({
									path: "/underwrite/info/" + applNum + "/" + "hbgzc"
								});
							}
						}
						console.log(res.data);
					} else {
						this.$alert(res.resultMsg, '错误信息', {
							confirmButtonText: '确定',
							callback: action => {
								this.$message({
									type: 'error',
									message: `action: ${action}`
								});
							}
						});
					}
					this.$store.dispatch('loading/CHANGE_LOADING', false);
				}).catch(err => {
					this.$store.dispatch('loading/CHANGE_LOADING', false);
				})
			},
			//核保选择 只取最前面一个
			hebao_select() {
				if (this.$refs.multipleTable.selection.length <= 0) {
					this.$message.error("请选择任务！");
					return;
				}
				this.hebao(this.$refs.multipleTable.selection[0].policyholderno, this.$refs.multipleTable.selection[0]
					.insuredno, this.$refs.multipleTable.selection[0].caseno);
			},
			//双击一行 核保
			hebao_dubclick(item) {
        // vip权限拦截 start
        let paramStr = JSON.stringify(item);
        if (paramStr.indexOf("****") > -1) {
          this.$message.error("本单是VIP保单，不允许查看！");
          return;
        }
        // vip权限拦截 end
				this.hebao(item.policyholderno, item.insuredno, item.caseno, item.organ);
			},
      // vip权限拦截
      interceptVip(row, index) {
          let rowStr = JSON.stringify(row);
          if (rowStr.indexOf("****") > -1) {
            return false;
          }
          return true;
      },
			// 每页多少条切换
			handleSizeChange(pageSize) {
				this.paginations.pageSize = pageSize;
				this.getList();
			},
			// 上下分页
			handleCurrentChange(page) {
				this.paginations.pageIndex = page;
				this.getList();
			},
			// 根据条件查询列表
			subGetList() {
				this.paginations.pageIndex = 1;
				this.getList();
			},

			handleSelectionChange(val) {
				this.multipleSelection = val;
			},

			// 清除查询条件
			resetSearch() {
				this.searchParams.caseno = '';
				this.searchParams.chdrnum = '';
				this.searchParams.channel = '';
				this.searchParams.appFrom = '';
				this.searchParams.routeid = '';
				this.searchParams.policyholdername = '';
				this.searchParams.insuredname = '';
				this.searchParams.taskTypeOrder = "routeid asc";
				this.searchParams.taskLevelOrder = "";
				this.searchParams.taskDealtimeOrder = "dealtime asc";
				this.$refs.multipleTable.clearSort();
			},
			//选择指定列进行排序
			changeTableSort(column) {
				debugger;
				console.log(column);
				//获取字段名称和排序类型
				var fieldName = column.prop;
				var sortingType = column.order;
				//按照降序排序
				if (sortingType == "descending") {
					if (fieldName == "nodeName") {
						this.searchParams.taskTypeOrder = "routeid desc";
					}
					if (fieldName == "taskLevel") {
						this.searchParams.taskLevelOrder = "task_level desc";
					}

				} else {
					//按照升序排序
					if (fieldName == "nodeName") {
						this.searchParams.taskTypeOrder = "routeid asc";
					}
					if (fieldName == "taskLevel") {
						this.searchParams.taskLevelOrder = "task_level asc";
					}

				}
				this.getList();
				console.log(this.tableData);
			},
			//核保员需求，新增请求派单按钮
			call_distr_task() {
				if (this.mysqlUserInfo.headStatus == "0") {
					this.$message.error("总公司核保员，无需手动请求派单！");
					return false;
				}
				let userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
				let userId = userInfo.account;
				this.$store.dispatch('loading/CHANGE_LOADING', true);
				call(TaskConstants.apis["callTask"] + '?userId=' + userId + "&organ=" + this.organ, "post").then(result => {
					if (result.resultCode == constant.SUCCESS) {
						this.$message({
							message: "请求派单成功！",
							type: "success",
							showClose: true,
							duration: 15000
						});
						this.getList();
					}
					this.$store.dispatch('loading/CHANGE_LOADING', false);
				}).catch(err => {
					this.$store.dispatch('loading/CHANGE_LOADING', false);
				})
			}
		},
		watch: {
			ssyMap: function(newVal) {
				console.log(newVal);
				console.log(this.ssyMap);
				//重新渲染table
				this.tableData.forEach(item => {
					item["orgName"] = this.getOrgName(item.organ);
				});
				this.tableData.push({});
				this.tableData.pop();
				console.log(this.tableData);
				console.log("重新渲染table");
			},
			nodeMap: function(newVal) {
				//重新渲染table
				this.tableData.forEach(item => {
					item["nodeName"] = this.getNodeName(item.routeid);
				});
				this.tableData.push({});
				this.tableData.pop();
				console.log(this.tableData);
				console.log("重新渲染table");
			},
		},
		computed: {
			...mapGetters(['tags']),
		},

	}
</script>
<style>
	.el-table .warning-row .cell {
		color: oldlace !important;
	}

	.el-table .success-row .cell {
		color: #f76767 !important;
	}
</style>
<style lang="less" scoped>
	.fillcontain {
		padding-bottom: 0;

		.fastQuery {
			padding: 15px 20px 10px 20px;
			background: #fff;
			border-bottom: 1px solid #e1e1e1;

			.fastQuery_title {
				color: #666;
				padding: 6px 0px;
			}

			.fastQuery_item {
				margin: 0 10px;
			}

			.item_default {
				.el-button {
					color: #409EFF !important;
					border-color: #c6e2ff !important;
					background-color: #ecf5ff !important;
				}

			}

			.moreCondition {
				color: #68a3fc;
				cursor: pointer;
				padding: 6px 0px;

				.el-icon-d-arrow-right {
					transform: rotate(90deg);
				}

				.el-icon-d-arrow-left {
					transform: rotate(-90deg);
				}
			}
		}
	}

	.contain {
		background: #fff;
		padding: 10px;
		margin-bottom: 20px;
	}

	.pagination {
		padding: 10px 20px;
		text-align: right;
	}

	.operationIcon {
		// padding: 12px;
		border: 1px solid #e5e5e5;
		border-radius: 50%;
		width: 22px;
		height: 22px;
		display: inline-block;
		cursor: pointer;
		box-shadow: 0 0 3px #f9f9f9;

		.svg-icon {
			font-size: 14px;
			fill: #68a3fc;
		}
	}

	.search_container {
		padding: 20px 20px 0 20px;
	}

	.el-dropdown {
		vertical-align: top;
	}

	.el-dropdown+.el-dropdown {
		margin-left: 15px;
	}

	.el-icon-arrow-down {
		font-size: 12px;
	}
</style>
